package com;

import com.fz.entity.Student;
import com.fz.mapper.StudentMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by webrx on 2017-09-01.
 */
public class Demo {
    //测试实用自动生成
    @Test
    public void cc(){
        try {
            InputStream im= Resources.getResourceAsStream("mybatis-config.xml");
            SqlSessionFactory sf=new SqlSessionFactoryBuilder().build(im);
            SqlSession ss=sf.openSession();
            StudentMapper stu=ss.getMapper(StudentMapper.class);
            Student st=new Student();
            st.setName("鱼撞撞3");
            st.setAddress("shengcheng");
            st.setScore(33);

            System.out.println(stu.insert(st));
            ss.commit();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
